<?php
/*
 * Created on 20 mars 2009 
 * Created by Ludovic Reenaers
 * lreenaers@hotmail.com
 * 
 * ex: Validator::validateEmail($str);
 */
 class Validator{
 	public static function validateEmail($email){
 		if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email) and (strlen($email) > 0 and strlen($email) < 256)) {
  			return true;
  		}else {
  			return false;
		}
 	}
 	public static function validateIp($ip){
 		if(preg_match("^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}^", $ip)) {
  			return true;
  		}else {
  			return false;
		}
 	}
 	public static function validateDate($day,$month,$year){
 		//min 6 char
 		if(checkdate($month,$day,$year)){
 			return true;
 		}else{
 			return false;
 		}
 	}
 	public static function validatePassword($pws){
 		//min 6 char
 		if(strlen($pws)>5){
 			return true;
 		}else{
 			return false;
 		}
 	}
 	public static function validateHash($hash){
 		// 32 char alphanumeric only
 		if(strlen($hash)==32 and ctype_alnum($hash)){
 			return true;
 		}else{
 			return false;
 		}
 	}
 }
?>
